Fix Critical Test Initialization Failures: Lazy LLMClient Init, Pydantic v2 Schema, and Import Paths#520
Open
Jean-Regis-M wants to merge 2 commits into
Conversation
- Add finbot/aegis/telemetry/schema.py with AuditEvent models - Add AEGIS_ENABLED and AEGIS_TELEMETRY_ENABLED settings - Extend events.py to support 'aegis.*' namespaces - Add unit tests for telemetry schema - Update conftest.py for aegis package discovery Week 1 deliverable - GSoC 2026 OWASP FinBot AEGIS
…antic v2 schema, import paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #519 Test Failures and Schema Validation Errors
Description
This PR addresses three critical issues blocking the test suite execution:
These fixes enable the test suite to run successfully without requiring external API credentials and fix type validation issues for schema generation.
Status: Ready for Review
Related Issue: #519
GSoC Context: Week 1 - AEGIS Telemetry Pipeline
Type of Change
Changes Made
1. Lazy LLMClient Initialization (
finbot/core/llm/client.py)Problem: Module-level instantiation blocked test execution when
OPENAI_API_KEYwas not setChanges:
Benefits:
LLM_PROVIDER="mock"before initializationFiles Modified:
finbot/core/llm/client.py2. Pydantic v2 Schema Validation Updates (
finbot/aegis/telemetry/schema.py)Change 2A: Add Literal Import
Change 2B: Update Event Class Type Fields
Applied to all event classes:
ToolCallEvent→Literal[EventType.TOOL_CALL.value]ToolResultEvent→Literal[EventType.TOOL_RESULT.value]MemoryWriteEvent→Literal[EventType.MEMORY_WRITE.value]DelegationEvent→Literal[EventType.DELEGATION.value]PolicyDecisionEvent→Literal[EventType.POLICY_DECISION.value]AnomalyDetectionEvent→Literal[EventType.ANOMALY_DETECTION.value]Change 2C: Replace Deprecated Config with ConfigDict
Benefits:
PydanticDeprecatedSince20warningsLiteraltypesFiles Modified:
finbot/aegis/telemetry/schema.py(6 event classes updated)3. Fix Import Path (
finbot/aegis/telemetry/routes.py)Problem:
get_session_contextis located inmiddleware.py, notsession.pyChanges:
Benefits:
ImportError: cannot import name 'get_session_context'Files Modified:
finbot/aegis/telemetry/routes.py4. Configure Test Environment (
tests/conftest.py)Problem: Tests required OpenAI API key even for mock testing
Changes:
Benefits:
LLM_PROVIDER="mock"before module importsFiles Modified:
tests/conftest.pySummary of Files Changed
finbot/core/llm/client.pyfinbot/aegis/telemetry/schema.pyfinbot/aegis/telemetry/routes.pytests/conftest.pyTotal Files Modified: 4
Total Lines Changed: ~50
Breaking Changes: 0
Testing
Test Execution
Test Results
Before Fix
After Fix
Test Coverage
Verification Checklist
Breaking Changes
✅ NONE - This is a non-breaking change
All changes are:
Dependencies
Added: None
Modified: None
Removed: None
All changes use existing project dependencies:
pydantic>=2.0typing(standard library)Deployment Notes
Pre-Deployment
Deployment
mainbranchPost-Deployment
OPENAI_API_KEYGSoC Context
Week 1 Task Progress
Impact
Performance Impact
Memory: Negligible (lazy initialization reduces startup cost)
Speed: Improved (no unnecessary client initialization)
CPU: No impact
Disk: No impact
Code Review Recommendations
Related Documentation
Author Notes
This PR resolves critical blockers preventing the test suite from executing. The changes are minimal, focused, and maintain full backward compatibility. All modifications follow Pydantic v2 best practices and Python typing standards.
The lazy initialization pattern for
LLMClientis a common best practice that allows environment-specific configuration before initialization.Checklist for Maintainers
PR Created: May 30, 2026
GSoC Week: Week 1
Status: Ready for Review
Urgency: CRITICAL - Blocks all testing
Additional Context
Why These Changes Matter
These changes are foundational for the AEGIS telemetry pipeline implementation and must be in place before Week 1 tasks can be verified.